home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright (C) 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
- #ifndef _ENTRY_
- #define _ENTRY_
-
- #include <stdio.h>
- #include <malloc.h>
- #include <string.h>
-
- #define MAX_ALARM_NOTIFICATIONS 64
- #define ALL_NOTIFICATIONS -1
-
- enum EntryKind { E_none,
- E_single,
- E_repeatDaily,
- E_repeatWeekDaily,
- E_repeatWeekly,
- E_repeatBiWeekly,
- E_repeatMonthlyDate,
- E_repeatMonthlyDay,
- E_repeatMonthlyDateEnd,
- E_repeatMonthlyDayEnd,
- E_repeatYearly };
-
- class Entry;
-
- typedef struct {
- EntryKind kind;
- char *string;
- } EntryKindInfo;
-
- typedef struct {
- Entry *entry;
- void *alarm;
- void *data;
- } EntryAlarmInfo;
-
- extern const EntryKindInfo entryKindList[];
- extern const int entryKindCount;
-
- class Entry {
- public:
- Entry();
- ~Entry();
-
- int day() { return _day; }
- int month() { return _month; }
- int year() { return _year; }
- int start() { return _start; }
- int length() { return _length; }
- void setTime(int start, int length)
- { _start = start; _length = length; }
-
- EntryKind kind() { return _kind; }
- void setKind(EntryKind k) { _kind = k; }
- int repeating() { return (_kind != E_none && _kind != E_single);}
-
- int notifyPopup() { return _notifyPopup; }
- void setNotifyPopup(int v) { _notifyPopup = v; }
- int notifyBell() { return _notifyBell; }
- void setNotifyBell(int v) { _notifyBell = v; }
- int notifyMail() { return _notifyMail; }
- void setNotifyMail(int v) { _notifyMail = v; }
- char *notifyCommand() { return _notifyCommand; }
- void setNotifyCommand(char *v);
-
- int alarmFired(int alarmIndex) { return _alarmFired[alarmIndex]; }
- void setAlarmFired(int v, int alarmIndex);
- int annotate() { return _annotate; }
- void setAnnotate(int a) { _annotate = a; }
- char *alarmAdvance() { return _advance; }
- int setAlarmAdvance(char *str);
-
- char *text() { return _text; }
- int setText(char *t);
-
- Entry *next() { return _next; }
- void setNext(Entry *d) { _next = d; }
-
- void *data() { return _data; }
- void setData(void *d) { _data = d; }
- void *snoozeData() { return _snoozeData; }
- void setSnoozeData(void *d) { _snoozeData = d; }
-
- EntryAlarmInfo *alarmInfo() { return _alarmInfo; }
-
- int alarmApplies(int time, int *alarmIndex,
- int unfiredOnly = 1);
- int alarmApplies(int day, int month, int year, int *alarmIndex,
- int *matchDay, int *matchMonth, int *matchYear,
- int unfiredOnly = 1);
-
- virtual void setDate(int day, int month, int year);
- virtual int readEntry(FILE *fd, int version);
- virtual void writeEntry(FILE *fd, int annotate);
- virtual void printEntry(FILE *fd, int clock24);
- virtual int daysInAdvance(int days, int day, int month, int year,
- int *matchDay, int *matchMonth, int *matchYear);
-
- protected:
- char *reformatAdvanceString(char *str);
- int parseAdvance(char *str, char **remainder);
-
- int _day, _month, _year;
- int _start, _length;
- EntryKind _kind;
- int _notifyPopup, _notifyBell, _notifyMail;
- char *_notifyCommand;
- int _alarmFired[MAX_ALARM_NOTIFICATIONS];
- Entry *_next, *_next2;
- char *_text;
- int _annotate;
- char *_advance;
- void *_data, *_snoozeData;
- EntryAlarmInfo *_alarmInfo;
- };
-
- class RepeatingEntry : public Entry {
- public:
- RepeatingEntry();
- ~RepeatingEntry();
-
- int repeatEndDay() { return _repeatEndDay; }
- int repeatEndMonth() { return _repeatEndMonth; }
- int repeatEndYear() { return _repeatEndYear; }
- void setRepeatEnd(int day, int month, int year)
- { _repeatEndDay = day; _repeatEndMonth = month; _repeatEndYear = year; }
- int repeatApplies(int day, int month, int year);
- int weekday() { return _weekday; }
-
- RepeatingEntry *next() { return (RepeatingEntry *) _next; }
- void setNext(RepeatingEntry *d) { _next = d; }
-
- virtual void setDate(int day, int month, int year);
- virtual int readEntry(FILE *fd, int version);
- virtual void writeEntry(FILE *fd, int annotate);
- virtual int daysInAdvance(int days, int day, int month, int year,
- int *matchDay, int *matchMonth, int *matchYear);
- virtual int readDate(FILE *fd, int version);
- virtual void writeDate(FILE *fd, int annotate);
-
- protected:
- int _repeatEndDay, _repeatEndMonth, _repeatEndYear;
- RepeatingEntry *_nextRepeat;
- int _weekday;
- };
-
- #endif
-